#include <pt.h>
#include <pt_god_schedule.h>
#include <pt_mem.h>
#include <workqueue.h>
#include <drv_spi.h>

static void device_init(void)
{
//	pt_hw_spi_init();
}

#define HEAP_SIZE   8192
#if defined (__CC_ARM)
extern int $Super$$main(void);
/* re-define main function */
int $Sub$$main(void)
{
    static uint8_t heap_mem[HEAP_SIZE];
    pt_system_heap_init(&heap_mem[0], &heap_mem[HEAP_SIZE - 1]);
	
	pt_work_sys_workqueue_init();
	
	device_init();
	
#if defined (__CC_ARM)
    $Super$$main(); /* for ARMCC. */
#elif defined(__ICCARM__) || defined(__GNUC__)
    main();
#endif

	pt_god_schedule();	//后台调度协程
    return 0;
}
#elif defined(__ICCARM__)

// extern int main(void);
// __low_level_init will auto called by IAR cstartup 

// extern void __iar_data_init3(void);
// int __low_level_init(void)
// {
    // call IAR table copy function.
    // __iar_data_init3();
    // rt_hw_interrupt_disable();
    // rtthread_startup();
    // return 0;
// }

#elif defined(__GNUC__)
extern int main(void);
// /* Add -eentry to arm-none-eabi-gcc argument */
// int entry(void)
// {
    // rt_hw_interrupt_disable();
    // rtthread_startup();
    // return 0;
// }
#endif

